package com.zjw.core.algorithm;

public class BubbleSort {

    public static void main(String[] args) {
        int[] arr = new int[]{1,4,5,2,46,24,11};
        bubbleSort(arr);
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }

        
    }
    
    private static void bubbleSort(int[] arr){
        int i,j,temp;
        for (i = 0; i < arr.length -1; i++) {
            for (j = 0; j < arr.length -1 -i; j++) {
                if(arr[j] > arr[j+1]){
                    temp = arr[j];
                    arr[j] = arr[j+1];
                    arr[j+1] = temp;
                }
            }
        }
    }
}
